package com.lipaluma.field.validator;

import java.lang.reflect.Field;
import java.util.List;

import com.lipaluma.context.Context;
import com.lipaluma.xml.validator.XmlValidator;

/**
 * validator permits validate value of the entry file parsed
 * @author Mario
 */
public interface Validator {
		
	/**
	 * initialize the validator by the field and annotation.<p>
	 * Returns true if initialisation pass
	 * @param context TODO
	 * @param field the field
	 * @return boolean
	 */
	boolean init(Context context, Field field);

	/**
	 * initialize the validator by the field and the column element from the xml configuration file.<p>
	 * Returns true if initialisation pass
	 * @param context TODO
	 * @param field the field
	 * @return boolean
	 */
	boolean init(Context context, Field field, XmlValidator validator);

	/**
	 * do the validation of the value. If errors occurs, the errors list will contains the error information
	 * @param value the value to validate
	 * @param errors validation's errors are added in this list
	 * @return boolean to indicate the success of validation
	 */
	boolean validate(Object value, List<ValidationError> errors);

}
